CXX = g++
CXXFLAGS = -I/usr/include/opencv -O3 -g -Wall -Wextra 
LDFLAGS = -L/usr/lib/opencv -ljpeg -lpthread -lm -lcv -lcxcore -lhighgui -lcvaux lstdc++
 
# name of the executable that will be created
TARGET = vision_test
# directory of the source files .cpp and .h
SRCDIR = .
# directory of the binary files .o
BINDIR = ./bin
# directory of the dependency files .d
DEPDIR = ./dep
# directory used by 'tarball' target to store archives .tar.gz
ARCHIVESDIR = .
# name of the makefile
MAKEFILE = Makefile
 
 
 
SRC = $(wildcard $(SRCDIR)/*.cc)
OBJ = $(patsubst $(SRCDIR)/%.cc,$(BINDIR)/%.o,$(SRC))
 
 
all: $(TARGET)
 
# link
$(TARGET): $(OBJ)
	$(CXX) -o $@ $^ $(LDFLAGS)

 
# compile and generate dependency info
$(BINDIR)/%.o: $(SRCDIR)/%.cc $(MAKEFILE)
	@mkdir -p $(BINDIR) $(DEPDIR)
	$(CXX) -c $< $(CXXFLAGS) -o $@
	@$(CXX) -MM $(CXXFLAGS) -MT $(BINDIR)/$*.o $< > $(DEPDIR)/$*.d
 
 
.PHONY: temprm clean mrproper
 
 
# cleaners
temprm:
	@rm -f $(SRCDIR)/*~ *~
 
clean: temprm
	@rm -f $(OBJ) $(DEP)
 
mrproper: clean
	@rm -f $(TARGET)
	@rm -rf $(BINDIR) $(DEPDIR)